﻿cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
project(camsense_lidar_driver LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 14)
#加载自定义模块
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")


#设置库文件可执行程序路径
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/../third_party/install)
include_directories(${CMAKE_INSTALL_PREFIX}/include)
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
#设置子模块
file(GLOB_RECURSE USER_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp)
file(GLOB_RECURSE USER_CPP_H RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/*.h)

# find_package
add_library(${PROJECT_NAME} STATIC
        ${USER_CPP}
        ${USER_CPP_H} src/lidar_scan.cpp src/lidar_scan.h)

#引用头文件路径
target_include_directories(${PROJECT_NAME}
        PUBLIC ${OpenCV_INCLUDE_DIRS}
        PUBLIC ${GLOG_INCLUDE_DIRS}
        PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

target_link_libraries(${PROJECT_NAME}
        PUBLIC pthread)

set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}")

#安装静态库至系统目录
install(DIRECTORY ${PROJECT_SOURCE_DIR}/lib/ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib FILES_MATCHING PATTERN "*.a" PATTERN "*.so")
install(DIRECTORY ${PROJECT_SOURCE_DIR}/bin/ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
install(DIRECTORY ${PROJECT_SOURCE_DIR}/script/ DESTINATION ${CMAKE_INSTALL_PREFIX}/script/${PROJECT_NAME} FILES_MATCHING PATTERN "*")
install(DIRECTORY ${PROJECT_SOURCE_DIR}/resource/ DESTINATION ${CMAKE_INSTALL_PREFIX}/resource/${PROJECT_NAME} FILES_MATCHING PATTERN "*")
install(DIRECTORY ${PROJECT_SOURCE_DIR}/example/ DESTINATION ${CMAKE_INSTALL_PREFIX}/example/${PROJECT_NAME} FILES_MATCHING PATTERN "*")

#测试程序
add_subdirectory(example)
#add_subdirectory(test)